//
//  AboutMisCloudViewController.m
//  MISCloud
//
//  Created by goldeney on 13-9-17.
//  Copyright (c) 2013年 goldeneye. All rights reserved.
//

#import "AboutUsViewController.h"
#import "FunctionIntroduceViewController.h"
#import "TOWebViewController.h"

@interface AboutUsViewController ()

@property (nonatomic,strong) NSArray *listInfoArray;

@end

@implementation AboutUsViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        [self setTitle: @"关于我们"];
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.tableView.tableHeaderView = self.tableHeaderView;
    self.tableView.tableFooterView = self.tableFooterView;
    
    [self setAppName_Version];
}

//设置程序版本及名称
- (void)setAppName_Version
{
    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
    CFShow((__bridge CFTypeRef)(infoDictionary));
    
    NSString *app_Name = [infoDictionary objectForKey:@"CFBundleName"];
    NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
    
    self.labelAPPName.text = [NSString stringWithFormat:@"%@", app_Name];
    self.labelVersion.text = [NSString stringWithFormat:@"版本:V%@", app_Version];
    
    self.listInfoArray = @[@[@"新功能介绍", @"about_xgn"],
                        @[@"了解汇基产品", @"about_cplj"],
                        @[@"为汇基云评分", @"about_pj"]];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
//    return self.listInfoArray.count;
    return 0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier = @"UITableViewCellAbout";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    
    NSArray *valueArray = self.listInfoArray[indexPath.row];
    cell.textLabel.font = [UIFont systemFontOfSize:15];
    cell.textLabel.textColor = [UIColor colorWithWhite:0.1 alpha:0.85];
    cell.textLabel.text = valueArray[0];
    cell.imageView.image = [UIImage imageNamed:valueArray[1]];
    return cell;
}


#pragma mark
#pragma mark - UITableViewDelegate

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 44;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    if (indexPath.row == 0) { //新功能介绍
        FunctionIntroduceViewController *view = [[FunctionIntroduceViewController alloc] init];
        [self.navigationController pushViewController:view animated:YES];
        
    } else if (indexPath.row == 1) { //了解协砼产品
        TOWebViewController *webViewController = [[TOWebViewController alloc] initWithURLString:@""];
        webViewController.navigationButtonsHidden = YES;
        [self.navigationController pushViewController:webViewController animated:YES];
        
    } else if (indexPath.row == 2) { //为汇基云评分
        NSString *str = [NSString stringWithFormat:@"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=1148400485" ];
        if( ([[[UIDevice currentDevice] systemVersion] doubleValue]>=7.0)){
            str = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/app/id1148400485"];
        }
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
    }
    
}


@end
